package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.general.BaseBean;
import weaver.interfaces.jjy.duss.util.SAPComMehtod;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.Map;


/**
 * @program: ecology-9-demo
 * @description: 查询通过身份证查询人员在sap中是否存在
 * @author: Dusongsong
 * @create: 2019-12-03
 */
public class HMDSEL {

    public Map execute(Map<String, String> map) {
        BaseBean baseBean = new BaseBean();
        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZFM_HR_PERNR");
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理
        //入参为字段
        input.setValue("HMD", "JIEKNO");
        baseBean.writeLog("in---HMDSEL");
        //入参为表
        JCO.Table t0 = inputtable.getTable("PT0185");
        t0.appendRow();//追加行
        t0.setValue("01", "ICTYP");
        t0.setValue(map.get("ICNUM"), "ICNUM");

        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        Map<String, String> resultMap = new HashMap<String, String>();
        String[] tabs = {"PT0185"};
        String[] stu = {"EV_OUTPUT", "PS0000"};
        resultMap = SAPComMehtod.SAPreturnS(stu, out, tabs, Table00);
        JCO.releaseClient(myConnection);
        return resultMap;
    }

    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("ICNUM","522126199408174519");
        HMDSEL hmdsel = new HMDSEL();
        hmdsel.execute(map);
    }
}
